const handles = new Map<string, ((...args: any[]) => void)[]>();

export const eventManage = {
    on: (eventName: string, callback: (...args: any[]) => void) => {
        if (!handles.has(eventName)) {
            handles.set(eventName, []);
        }
        handles.get(eventName)?.push(callback);
    },
    emit: (eventName: string, ...request: any) => {
        if (handles.has(eventName)) {
            handles.get(eventName)?.forEach((callback) => {
                callback(...request);
            });
        }
    }
}